const util = require('../../utils/js/util')
const api = require('../../api/api')
Component({
  data: {
    safeToBottom: util.getSafeToBottom(),
    // kfcode: '',
    gzhcode: '',
    qrcodeIsShow: false,
    pop: {
      show: false,
      type: ''
    }
  },
  lifetimes: {
    async created() {
      const res = await api.getCodeConfig()
      this.setData({ gzhcode: res.qrcode2 })
    },
    attached() {
      
    },
    moved() {

    },
    detached() {

    },
  },
  pageLifetimes: {
    show: function() {
      
    },
    hide: function() {
      // 页面被隐藏
    },
    resize: function(size) {
      // 页面尺寸变化
    }
  },
  methods: {
    loadsuc() {
      this.setData({ qrcodeIsShow: false })
    },
    loaderr() {
      this.setData({ qrcodeIsShow: true })
    },
    close() {
      this.setData({ 'pop.show': false })
    },
    zc() {
      wx.showActionSheet({
        itemList: ['邀请奖励', '用工补贴'],
        success: ({tapIndex}) => wx.navigateTo({ url: `../../pages/article/index?id=${tapIndex + 1}` })
      })
    },
    concat() {
      wx.openCustomerServiceChat({
        extInfo: { url: 'https://work.weixin.qq.com/kfid/kfcb2b3b337c756fb7c' },
        corpId: 'wwc4cdca2b6b57f0a3',
        success: res => {},
        fail: err => {}
      })
    },
    gzh() {
      this.setData({ pop: {show: true, type: 'gzh'} })
    },
    kf() {
      this.setData({ pop: {show: true, type: 'kf'} })
    },
  },
});